<template>
  <view class="add-comment-page">
    <!-- 评论输入区域 -->
    <view class="comment-input-section">
      <view class="input-container">
        <textarea 
          class="comment-input" 
          placeholder="写下你对商家的留言"
          v-model="commentText"
          @input="handleInput"
        ></textarea>
      </view>
    </view>

    <!-- 确认按钮 -->
    <view class="confirm-section">
      <button 
        class="confirm-btn flex-center" 
        :class="{ disabled: !commentText.trim() }"
        @click="submitComment"
        :disabled="!commentText.trim()"
      >
        <text>确定</text>
      </button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      commentText: ""
    }
  },
  methods: {
    handleInput() {
      // 可以在这里添加输入处理逻辑，比如字数限制等
      if (this.commentText.length > 500) {
        this.commentText = this.commentText.substring(0, 500);
        uni.showToast({
          title: "评论内容不能超过500个字符",
          icon: 'none'
        });
      }
    },
    submitComment() {
      if (!this.commentText.trim()) {
        uni.showToast({
          title: "请输入评论内容",
          icon: 'none'
        });
        return;
      }

      // 这里可以添加提交评论的逻辑
      console.log("提交评论:", this.commentText);
      
      // 模拟提交成功
      uni.showToast({
        title: "评论提交成功！",
        icon: 'success'
      });
      
      // 返回上一页或跳转到评论页面
      uni.navigateBack();
    }
  },
  onLoad() {
    // 页面加载时的逻辑
    console.log("评论页面加载完成");
  }
}
</script>

<style lang="scss" scoped>
.add-comment-page {
  min-height: 100vh;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  padding: 40rpx;
}

/* 评论输入区域 */
.comment-input-section {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80rpx;
  
  .input-container {
    width: 100%;
    max-width: 1200rpx;
    background: white;
    border-radius: 24rpx;
    box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
    padding: 40rpx;
    
    .comment-input {
      width: 100%;
      min-height: 600rpx;
      border: none;
      outline: none;
      font-size: 32rpx;
      color: #333;
      line-height: 1.6;
      resize: none;
      font-family: inherit;
      
      &::placeholder {
        color: #999;
      }
    }
  }
}

/* 确认按钮 */
.confirm-section {
  margin-top: auto;
  padding: 20rpx 0;
  
  .confirm-btn {
    width: 100%;
    height: 100rpx;
    background: #ED6567;
    border: none;
    border-radius: 50rpx;
    font-size: 36rpx;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    
    &:hover:not(:disabled) {
      background: #d55a54;
      transform: translateY(-2rpx);
    }
    
    &:active:not(:disabled) {
      transform: translateY(0);
    }
    
    &.disabled {
      background: #ccc;
      cursor: not-allowed;
      transform: none;
      
      &:hover {
        background: #ccc;
        transform: none;
      }
    }
  }
}
</style>